//
//  LayoutBlockView.m
//  Layout
//
//  Created by  on 11-11-23.
//  Copyright (c) 2011年 __MyCompanyName__. All rights reserved.
//

#import "LayoutBlockView.h"

@implementation LayoutBlockView

@synthesize title;

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        // Initialization code
        self.opaque = NO;
    }
    return self;
}

- (void)drawRect:(CGRect)rect
{
    CGContextRef context = UIGraphicsGetCurrentContext();
	CGFloat frameColors[] = {0.5,0.8,0.6,1.0};
	CGContextSetStrokeColor(context, frameColors);
	CGContextStrokeRect(context, self.bounds);
	CGRect innerFrame = self.bounds;
	innerFrame.origin.x += 1;
	innerFrame.origin.y += 1;
	innerFrame.size.width -= 2;
	innerFrame.size.height -= 2;
	CGContextStrokeRect(context, innerFrame);
    
    
    UIFont *font = [UIFont systemFontOfSize:12.0f];
    CGSize textSize = [self.title sizeWithFont:font constrainedToSize:self.bounds.size];
    CGRect textRect = CGRectCenterRect(rect, textSize);
    [self.title drawInRect:textRect withFont:font];
}

@end
